package cn.stylefeng.guns.modular.港中旅加价规则设置.controller;

import cn.stylefeng.roses.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import cn.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import cn.stylefeng.guns.modular.system.model.PriceRaiseRule;
import cn.stylefeng.guns.modular.港中旅加价规则设置.service.IPriceRaiseRuleService;

/**
 * price_raise控制器
 *
 * @author fengshuonan
 * @Date 2019-01-07 17:44:22
 */
@Controller
@RequestMapping("/priceRaiseRule")
public class PriceRaiseRuleController extends BaseController {

    private String PREFIX = "/港中旅加价规则设置/priceRaiseRule/";

    @Autowired
    private IPriceRaiseRuleService priceRaiseRuleService;

    /**
     * 跳转到price_raise首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "priceRaiseRule.html";
    }

    /**
     * 跳转到添加price_raise
     */
    @RequestMapping("/priceRaiseRule_add")
    public String priceRaiseRuleAdd() {
        return PREFIX + "priceRaiseRule_add.html";
    }

    /**
     * 跳转到修改price_raise
     */
    @RequestMapping("/priceRaiseRule_update/{priceRaiseRuleId}")
    public String priceRaiseRuleUpdate(@PathVariable Integer priceRaiseRuleId, Model model) {
        PriceRaiseRule priceRaiseRule = priceRaiseRuleService.selectById(priceRaiseRuleId);
        model.addAttribute("item",priceRaiseRule);
        LogObjectHolder.me().set(priceRaiseRule);
        return PREFIX + "priceRaiseRule_edit.html";
    }

    /**
     * 获取price_raise列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return priceRaiseRuleService.selectList(null);
    }

    /**
     * 新增price_raise
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(PriceRaiseRule priceRaiseRule) {
        priceRaiseRuleService.insert(priceRaiseRule);
        return SUCCESS_TIP;
    }

    /**
     * 删除price_raise
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer priceRaiseRuleId) {
        priceRaiseRuleService.deleteById(priceRaiseRuleId);
        return SUCCESS_TIP;
    }

    /**
     * 修改price_raise
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(PriceRaiseRule priceRaiseRule) {
        priceRaiseRuleService.updateById(priceRaiseRule);
        return SUCCESS_TIP;
    }

    /**
     * price_raise详情
     */
    @RequestMapping(value = "/detail/{priceRaiseRuleId}")
    @ResponseBody
    public Object detail(@PathVariable("priceRaiseRuleId") Integer priceRaiseRuleId) {
        return priceRaiseRuleService.selectById(priceRaiseRuleId);
    }
}
